//
//  AppDelegate.m
//  UI03_UI
//
//  Created by LGC on 16/3/11.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import "MyView.h"
#import "LTView.h"
@interface AppDelegate ()
@property (nonatomic, retain) MyView *view;

@end

@implementation AppDelegate

- (void)dealloc {
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    /** 创建controller对象. */
    ViewController *VC = [[ViewController alloc]init];
    
    // 指定根视图控制器(进入APP之后看到的"界面")
    // 逻辑代码和UI基本都是在controller中编写.
    // 详见 ViewController.m文件.
    self.window.rootViewController = VC;
    
    [VC release];
    [_window release];

    return YES;
}

#pragma mark - 前一天作业
- (void)homeWork {
    MyView *view = [[MyView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    
    view.backgroundColor = [UIColor redColor];
    [self.window addSubview:view];
    [view release];
    
    //动画
    [UIView animateWithDuration:3 animations:^{
        view.frame = CGRectMake(200, 200, 200, 200);
    }];

}


#pragma mark - 知识点1: 自定义View(LTView)
- (void)creatCustomView {
    
    // create object
    LTView *viewOfUser = [[LTView alloc]initWithFrame:CGRectMake(40, 50, self.window.frame.size.width - 80 , 40) Text:@"用户名:" placeHolder:@"请输入用户名"];
    
    [self.window addSubview:viewOfUser];
    [viewOfUser release];
    
    viewOfUser.backgroundColor = [UIColor lightGrayColor];
   
    // password
    
    LTView *viewOfPassWord = [[LTView alloc]initWithFrame:CGRectMake(40, 110, self.window.frame.size.width - 80, 40) Text:@"密码:" placeHolder:@"请输入密码"] ;
    [self.window addSubview:viewOfPassWord];
    viewOfPassWord.backgroundColor = [UIColor lightGrayColor];
    [viewOfPassWord release];
 
    
}

#pragma mark - 知识点2: 视图控制器(UIViewController)

/** 详见, self.window创建代码段 */

#pragma mark - 知识点3: 视图控制器的声明周期

/** 详见.ViewController.m */

#pragma mark - 知识点4: viewController推出新页面

/** 详见, ViewController类 和 VCOfSecond类 */

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
